local skel = fk.CreateSkill {
  name = "lb_zero__qushan",
}

Fk:loadTranslationTable {
  ["lb_zero__qushan"] = "趋膳",
  [":lb_zero__qushan"] = "每回合限一次，当你需要使用<a href='#lb_zero__qushan_href'><font color='red'>牌面上含有正常可食用物的单目标基本牌或普通锦囊牌</font></a>时，你可以摸手牌数张牌，然后弃置摸牌数+1张牌，若弃置牌类型均相同，你视为使用之。",

  ["#lb_zero__qushan_href"] = "#\"<b>牌面上含有正常可食用物的单目标基本牌或普通锦囊牌</b>\"：仅限标准与军争牌堆，即【桃】、【酒】、【决斗】、【顺手牵羊】。",

  ["#lb_zero__qushan"] = "趋膳：你可以摸 %arg 张牌，然后弃置 %arg2 张牌，若弃置牌类型均相同，你视为使用以上一种牌",

  ["$lb_zero__qushan1"] = "开饭啦！",
  ["$lb_zero__qushan2"] = "瞧好啦！",
}

skel:addEffect("viewas", {
  anim_type = "control",
  pattern = "peach,analeptic,duel,snatch",
  prompt = function (self, player, selected_cards, selected)
    local num = player:getHandcardNum()
    return "#lb_zero__qushan:::" .. num .. ":" .. num + 1
  end,
  interaction = function(self, player)
    local all_choices = {"peach", "analeptic", "duel", "snatch"}
    local choices = player:getViewAsCardNames(skel.name, all_choices)
    if #choices > 0 then
      return UI.CardNameBox { choices = choices, all_choices = all_choices }
    end
  end,
  card_filter = Util.FalseFunc,
  view_as = function(self, player, cards)
    if not self.interaction.data then return nil end
    local card = Fk:cloneCard(self.interaction.data)
    card.skillName = skel.name
    return card
  end,
  before_use = function(self, player, use)
    local room = player.room
    local type_list = {}
    local num = player:getHandcardNum()
    if num > 0 then
      player:drawCards(num, skel.name)
      if not player:isNude() then
        num = num + 1
        local cards = room:askToDiscard(player, {
          min_num = num,
          max_num = num,
          include_equip = true,
          skill_name = skel.name,
          cancelable = false,
        })
        for _, id in ipairs(cards) do
          table.insertIfNeed(type_list, Fk:getCardById(id).type)
        end
      end
    end
    if #type_list ~= 1 then
      return skel.name
    end
  end,
  enabled_at_play = function(self, player)
    return player:usedSkillTimes(skel.name, Player.HistoryTurn) == 0 and not player:isKongcheng()
  end,
  enabled_at_response = function(self, player, response)
    return not response and player:usedSkillTimes(skel.name, Player.HistoryTurn) == 0 and not player:isKongcheng()
  end,
})

return skel
